/* *
 * Created by render on 2019-04-28
 * */
(function () {
  const container = document.querySelector('#content-container');


  function clacScale() {
    const designWidth = 1920;
    const designHeight = 1080;
    const Width = (document.body.clientWidth || document.documentElement.clientWidth);
    const Height = document.body.clientHeight || document.documentElement.clientHeight;
    const scaleHeight = (Height / designHeight).toFixed(3);
    container.style.transform = `scale(${scaleHeight})`;

    if( (designWidth / scaleHeight) < Width  ){
      $('#swiperWrapper').width( (Width/scaleHeight) + 'px' ).css('marginLeft', (-(Width / scaleHeight - designWidth) / 2) + 'px')
      $('#swiperWrapper1').width( (Width/scaleHeight) + 'px').css('marginLeft', (-(Width / scaleHeight - designWidth) / 2) + 'px')
    }else{
      $('#swiperWrapper').width((designWidth / scaleHeight) + 'px').css('marginLeft', (-(designWidth / scaleHeight - designWidth) / 2) + 'px')
      $('#swiperWrapper1').width((designWidth / scaleHeight) + 'px').css('marginLeft', (-(designWidth / scaleHeight - designWidth) / 2) + 'px')
      $('html').css('overflowX','hidden')
    }

    $('.screen-container-wrapper').each((key, item) => {
      if (item.className.indexOf('carinfo-pop') > -1) {
        item.style.transform = `scale(${scaleHeight}) translateY(-50%)`
      }else{
        item.style.transform = `scale(${scaleHeight})`
      }
    })

    if(designWidth*scaleHeight < Width){
      window.outter = true;
      container.style.position = 'absolute';
      container.style.left= (Width-(designWidth*scaleHeight))/2+'px';
      if(typeof(imgArray)!='undefined'){
        document.body.style.backgroundImage = 'url('+imgArray[0]+')';
      }
    }else{
      container.style.position = '';
      container.style.left = '';
      if(typeof(imgArray)!='undefined'){
        container.style.backgroundImage = 'url('+imgArray[0]+')';
      }
    }
  }

  let timer = null;
  function resizeHandler() {
    timer && clearTimeout(timer);
    timer = setTimeout(clacScale, 300);
  }

  clacScale();

  window.addEventListener('resize', function(){resizeHandler()});
})();
